package Algorithms;

public class insertionsort {
public insertionsort(Comparable[]a) {
	for(int i=0;i<a.length;i++) {
		for(int k=i;k>0&&less(a[k], a[k-1]);k--) {
			exch(a, k, k-1);
		}
	}
}
private static  boolean less(Comparable v,Comparable w) {
	return v.compareTo(w)<0;
}
private static void exch(Comparable[]a,int i,int min) {
	Comparable t=a[i];a[i]=a[min];a[min]=t;
} 
}
